﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using mvc3App.DataStore.Entities;
using mvc3App.DataStore.TableStorage;

namespace mvc3App
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "LikeAlcohol" in code, svc and config file together.
    public class LikeAlcohol : ILikeAlcohol
    {
        private TableStorage tableStorage = null; 

        private void NewTableStorage()
        {
            if (tableStorage == null)
                tableStorage = new TableStorage();
        }
        
        public List<Beverage> ListBeverages()
        {
            NewTableStorage();
            return tableStorage.ListBeverages();
        }

        public Guid SaveOccasion(Occasion occasion)
        {
            NewTableStorage();
            tableStorage.InsertEntities(occasion);
            return occasion.OccasionID;
        }

        public List<Occasion> ListOccasion(Guid userID)
        {
            NewTableStorage();
            return tableStorage.ListEntities(userID);
        }

        public Occasion GetOccasion(Guid occasionID)
        {
            NewTableStorage();
            return tableStorage.GetEntity(occasionID);
        }
    }
}
